1 <?php
2  session_start();
3  
if(isset($_SESSION['user']))
4  {
5
6  }
7  
else{
8   echo
"<script>location.href='login.html'</script>";
9  }
10 ?>
11 <!doctype html>
12 <html>
13 <head>
14         <title>Petproducts </title>
15         <style>
16   body {
17   margin:
0;
18   font-family: Arial, Helvetica, sans-serif;
19   background: #
484848;
20 }
21 .topnav {
22   overflow: hidden;
23   background-color: #f44336;
24   height: 70px;
25   border: 3px solid #ff0000;
26 }
27
28 .topnav a {
29   
float: left;
30   color: #f2f2f2;
31   text-align: center;
32   padding: 14px 16px;
33   text-decoration: none;
34   font-size: 35px;
35   font-weight: bold;
36 }
37
38 .topnav-right {
39   
float: right;
40 }
41 fieldset {
42   background: #FAFAFA;
43     padding: 10px;
44    margin:auto;
45    max-width:450px;
46     box-shadow: 1px 1px 25px rgba(
0, 0, 0, 0.35);
47     border-radius: 10px;
48     border: 6px solid #f44336;
49
50
51 }
52
53
54             
55     </style>
56 </head>
57 <body>
58 <div
class="topnav">
59             <a
class="active" href="home.html"><img src="ic_add_pet.png"></a>
60             <a href=
"petproducts.php">pets products</a>
61             <div
class="topnav-right">
62               <a href=
"logout.php">logout</a>
63             </div>
64           </div>
65     <form>
66         <button type=
"submit" formaction="petproducts.php" style="margin:15px;height: 30px;width: 100px;
67         border-radius:15px;
68 border: 3px solid #ff0000;background-color:#f44336;color:#f2f2f2;font-size:17px;cursor:pointer;"
>back</button>
69 </form>
70 <form method=
"post" action="productupdate.php">
71 <fieldset>
72    <input type=
"text" name="id" placeholder=" Enter product_id" style="width:100%;height:30px;
73    border: 2px solid #f44336; border-radius:3px; background:transparent;"
required>
74   <br><br>
75   <input type=
"text" name="name" placeholder=" Enter product name" style="width:100%;height:30px;
76    border: 2px solid #f44336; border-radius:3px; background:transparent;"
required>
77   <br><br>
78    <input type=
"text" name="type" placeholder=" Enter product type" style="width:100%;height:30px;
79    border: 2px solid #f44336; border-radius:3px; background:transparent;"
required>
80   <br><br>
81   <input type=
"number" name="cost" placeholder=" Enter cost" style="width:100%;height:30px;
82    border: 2px solid #f44336; border-radius:3px; background:transparent;"
min="0" required>
83   <br><br>
84   <input type=
"text" name="belong" placeholder=" which pet category it belongs to" style="width:100%;height:30px;
85    border: 2px solid #f44336; border-radius:3px; background:transparent;"
required>
86   <br><br>
87   <input type=
"submit" name="submit" value="update" placeholder=" which pet category it belongs to" style="width:100%;height:30px;
88    border: 2px solid #f44336; border-radius:3px; cursor:pointer;background-color:#f44336"
>&ensp;
89 </fieldset>
90 </form>
91 </body>
92 </html>
93 <?php

94 if
(isset($_POST["submit"]))
95 {

96 // define variables and
set to empty values
97 $servername =
"localhost";
98 $username =
"root";
99 $password =
"";
100 $dbname =
"Petshop_management";
101
102 // Create connection

103 $conn =
new mysqli($servername, $username, $password, $dbname);
104 // Check connection

105 if
($conn->connect_error) {
106     die(
"Connection failed: " . $conn->connect_error);
107 }

108 //echo
" CONNECTION ESTABLISHED \r\n";
109 //echo
" INSERTION IN PROCESS";
110 $id = $_POST[
"id"];
111   $name = $_POST[
"name"];
112   $type= $_POST[
"type"];
113   $belongs = $_POST[
"belong"];
114   $cost = $_POST[
"cost"];
115
116   $Query2=
"select count(*) from pet_products where pp_id='$id'";
117   $Execute = mysqli_query($conn,$Query2);
118   $count = mysqli_fetch_row($Execute);
119   
if($count[0]==1)
120   {
121     $sql =
"UPDATE pet_products SET pp_name='$name' ,pp_type= '$type',cost='$cost' ,belongs_to='$belongs'
122     WHERE pp_id='$id'"
;
123     
if ($conn->query($sql) == TRUE) {
124       echo
'<div>
125       <h1 style=
"color:#f2f2f2;font-size:20px; font-family: "Roboto", sans-serif;margin:auto;">'
126       .$id.
' updated successfully</h1>
127          </div>
';
128     }
else {
129         echo
"Error: " . $sql . "<br>" . $conn->error;
130     }
131   }
132   
else{
133     echo
'<div>
134     <h1 style=
"color:#f2f2f2;font-size:30px; font-family: "Roboto", sans-serif;margin:auto;">Given pp_id not found</h1>
135        </div>
';
136 }
137
138
139 $conn->close();
140 }
141 ?>


Gõ tìm kiếm nhanh...